package com.atguigu.chapter05.Transform;

import com.atguigu.chapter05.WaterSensor;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * TODO
 *
 * @author cjp
 * @version 1.0
 * @date 2021/3/3 15:29
 */
public class Flink06_Shuffle {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);

        DataStreamSource<String> inputDS = env.readTextFile("input/sensor.csv");

        inputDS.print("input");

        // TODO Transform -  Shuffle : 洗牌打散
        // Shuffle分区器： random.nextInt(下游分区数)
        DataStream<String> shuffle = inputDS.shuffle();

        shuffle.print("shuffle");


        env.execute();
    }
}
